import java.io.IOException;

public class RunVoting {
	   public static void main (String[] args) {
	       MyBufferedReader in = new MyBufferedReader(System.in);
	       String s;
	       try {
	           s = in.readLine();
	           in.readLine();}
	       catch (IOException e) {
	           throw new RuntimeException();
	           }
	       int sets = Integer.parseInt(s);//sets
	           for(int z = sets; z > 0; --z){//sets loop
	        	  if(AustralianVoting.read(in)){
		              AustralianVoting.eval();
		               if(z>1){
		                       System.out.println();}
		
		           }
	           }
	   }
	}



